<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>用户过滤配置</title>
<@fm.header />
<script>
function doSearch() {
    $('#tt').datagrid('load', {
        apkName : $('#apkName').val(),
        filterType : $('#filterType').combobox('getValue')
    });
    $('#tt').datagrid('unselectAll');
}

function add(){
    showMyWindow('用户过滤配置 | 新建过滤', '/apkFilter/add', 400, 350);
}
function edit(){
	var row = $('#tt').datagrid('getSelected');
    if (row){
	    showMyWindow('用户过滤配置 | 编辑过滤', '/apkFilter/'+row.id+'/update', 400, 350);
    } else {
    	showMsg(market.content.title, market.content.tips, alert);
    }
}
function del(){
	var row = $('#tt').datagrid('getSelected');
    if (row){
	   showConfirm(market.content.title, market.content.confirm, function(){
		  $.post('/apkFilter/'+row.id+'/delete', function(data) {
		  	if (data.return_code == '1') {
				top.showMsg(market.content.title, data.return_msg, alert);
				$("#tt").datagrid('reload');
			} else {
				$.messager.alert(market.content.title, data.return_msg);
			}
		  });
	   });
    } else {
    	showMsg(market.content.title, market.content.tips, alert);
    }
}


function formatterApkList(value, row, index) {
    return '<a href="#" onclick="editApkList(' + "'" + row.id + "'" + ')">配置</a> ';
}

function editApkList(id) {
    showMyWindow('选择包', '/apkFilter/' + id + '/apkList', 800, 400);
}
</script>
</head>
<body class="cmp-list-body">
<div id="tb" style="padding:3px">

    <span>关键字</span>
    <input id="apkName" class="easyui-textbox" style="width: 155px;" name="apkName"/>

    <span>过滤状态</span>
    <select class="easyui-combobox" id="filterType" panelHeight="auto" style="width:155px" >
        <option value="-1">-选择-</option>
        <option value="1">可用</option>
        <option value="2">不可用</option>
    </select>

    <a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="doSearch();">查询</a> 
    <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add();">新增</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="del();">删除</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="edit();">修改</a>
</div>
<table id="tt" class="easyui-datagrid" title="用户过滤配置 | 过滤列表" iconCls="icon-save" 
	url="/apkFilter/list?json" toolbar="#tb" rownumbers="true" idField="ver"
	singleSelect="true" pagination="true" fitColumns="true" pageSize="15" pageList="[15,30,60,80,100]"> 
    <thead>
        <tr>
            <th align="center" width="10%" field="baseName">基地</th>
            <th align="center" width="25%" field="sdkVersion">过滤版本</th>
            <th align="center" width="25%" field="sdkFilterKeyword">过滤关键字</th>
            <th align="center" width="25%" field="filterTypeName">过滤类型</th>
            <th align="center" width="25%" field="apkList" formatter="formatterApkList">配置包</th>
            <th align="center" width="20%" field="createTime">创建时间</th>
            <th align="center" width="20%" field="modifyTime">更新时间</th>
        </tr>
    </thead>   
</table>
</body>
</html>